  const loginIdValidator = new FieldValidator('txtLoginId', async function(val) {
      if (!val) {
          return '账号不得为空'

      }
      const resp = await API.exists(val)
      console.log(resp)
      if (resp.data) {
          return '该账号已被占用，请重新填写'
      }
  })
  const nicknameValidator = new FieldValidator('txtNickname', function(val) {
      if (!val) {
          return '请填写昵称'
      }
  })
  const loginPwdValidator = new FieldValidator('txtLoginPwd', function(val) {
      if (!val) {
          return '请填写密码'
      }
  })
  const PwdConfirmValidator = new FieldValidator('txtLoginPwdConfirm', function(val) {
      if (!val) {
          return '请再次填写密码'
      }
      if (val !== loginPwdValidator.input.value) {
          return '两次密码不一致'
      }

  })
  const from = $('.user-form');
  from.onsubmit = async function(e) {
      e.preventDefault();
      const result = await FieldValidator.validate(
          loginIdValidator,
          nicknameValidator,
          loginPwdValidator
      )
      if (!result) {
          return
      }
      const fromDate = new FormData(from);
      const date = Object.fromEntries(fromDate.entries())
      const resp = await API.reg(date)
      if (resp.code === 0) {
          console.log(resp)
          alert('注册成功，点击跳转进入登陆页面')
          location.href = './login.html';
      }
  }